<template>
  <div class="box">
    <div class="top">
      <p class="title">实时游客统计</p>
      <p class="bg"></p>
      <p class="right">可预约总量<span>99999</span></p>
    </div>
    <div class="number">
      <span v-for="(item, index) in people" :key="index">{{ item }}</span>
    </div>
    <!-- Echarts水晶球展示 -->
    <div class="charts" ref="chartsRef">2</div>
  </div>
</template>

<script setup lang="ts">
import * as echarts from "echarts";
import { ref, onMounted } from "vue";
// 水球图拓展插件
import "echarts-liquidfill";
const people = ref("213435人");
// 获取图表实例
const chartsRef = ref();
onMounted(() => {
  // 获取图表实例
  const myCharts = echarts.init(chartsRef.value);
  // 设置实例的配置项
  myCharts.setOption({
    // 系列:决定展示什么类型的图表
    series: {
      type: "liquidFill", // 系列
      data: [0.6, 0.4, 0.2], // 展示的数据
      waveAnimation: true, // 水波动画
      animationDuration: 3, // 动画时长
      animationDurationUpdate: 0,
      radius: "95%", // 半径
      outline: {
        show: true,
        borderDistance: 8,
        itemStyle: {
          color: "skyblue",
          borderColor: "#294D99",
          borderWidth: 8,
          shadowBlur: 20,
          shadowColor: "rgba(0, 0, 0, 0.25)",
        },
      },
    },
    // 布局组件
    grid: {
      left: 0,
      top: 0,
      right: 0,
      bottom: 0,
    },
  });
});
</script>

<style scoped lang="scss">
.box {
  background: url(../../images/dataScreen-main-lb.png) no-repeat;
  background-size: 100% 100%;
  margin-top: 10px;

  .top {
    margin-left: 20px;
    .title {
      color: white;
      font-size: 20px;
    }
    .bg {
      width: 68px;
      height: 7px;
      background: url(../../images/dataScreen-title.png) no-repeat;
      background-size: cover;
      margin-top: 10px;
    }

    .right {
      float: right;
      color: white;
      font-size: 20px;
      margin-right: 10px;

      span {
        color: yellowgreen;
        margin-left: 5px;
      }
    }
  }

  .number {
    margin-top: 50px;
    display: flex;
    padding: 10px;

    span {
      flex: 1;
      height: 60px;
      text-align: center;
      line-height: 60px;
      background: url(../../images/total.png) no-repeat;
      background-size: cover;
      color: #29fcff;
      font-size: 30px;
    }
  }

  .charts {
    width: 100%;
    height: 250px;
  }
}
</style>
